package com.qianji.controller;

import com.qianji.pojo.PVUVDto;
import com.qianji.service.PVUVService;
import com.qianji.utils.Result;
import com.qianji.vo.PVUV;
import com.qianji.vo.PVUVVO;
import io.swagger.annotations.ApiOperation;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/pv_uv/")
public class PVUVController {

    @Autowired
    private PVUVService pvuvService;

    @ApiOperation("新增PV")
    @RequestMapping(value = "pv", method = RequestMethod.POST)
    public Result addPV(@RequestBody PVUVVO pvuv){
        log.info("进入了user PV，入参：{}",pvuv);
        return pvuvService.addPV(pvuv.getData());
    }

    @ApiOperation("新增UV")
    @RequestMapping(value = "uv", method = RequestMethod.POST)
    public Result addUV(@RequestBody PVUVVO pvuv){
        synchronized (this){
            log.info("user uv 入参：{}",pvuv.toString());
            return pvuvService.addUV(pvuv.getData());
        }
    }


}
